package com.zoo.diannaopeijian.service.impl;

import com.zoo.diannaopeijian.comm.page.Page;
import com.zoo.diannaopeijian.comm.sql.GeneratorExampleBuilder;
import com.zoo.diannaopeijian.domain.ComponentParameterDetail;
import com.zoo.diannaopeijian.domain.ComponentParameterDetailExample;
import com.zoo.diannaopeijian.mapper.ComponentParameterDetailMapper;
import com.zoo.diannaopeijian.service.ComponentParameterDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zx583 on 2018-01-15.
 */
@Service
public class ComponentParameterDetailServiceImpl implements ComponentParameterDetailService {

    @Resource
    private ComponentParameterDetailMapper componentParameterDetailMapper;

    @Override
    public boolean addComponentParameterDetail(ComponentParameterDetail componentparameterdetail) {
        return componentParameterDetailMapper.insertSelective(componentparameterdetail) == 1;
    }

    @Override
    public boolean updateComponentParameterDetail(ComponentParameterDetail componentparameterdetail) {
        return componentParameterDetailMapper.updateByPrimaryKeySelective(componentparameterdetail) == 1;
    }

    @Override
    public boolean deleteComponentParameterDetail(Integer componentparameterdetailid) {
        return componentParameterDetailMapper.deleteByPrimaryKey(componentparameterdetailid) == 1;
    }

    @Override
    public List<ComponentParameterDetail> getComponentParameterDetail(ComponentParameterDetail componentparameterdetail) {
        ComponentParameterDetailExample example = (ComponentParameterDetailExample) GeneratorExampleBuilder.buildEqualExample(ComponentParameterDetailExample.class, componentparameterdetail, true);

        return componentParameterDetailMapper.selectByExample(example);
    }

    @Override
    public List<ComponentParameterDetail> getComponentParameterDetailWithPage(ComponentParameterDetail componentparameterdetail, Page page) {
        page.onPage();

        return getComponentParameterDetail(componentparameterdetail);
    }

}
